
using CStock;
using System;
using System.Diagnostics;
using NUnit.Framework;
using System.Collections;
using CGraph;
using System.Data;
using System.Reflection;
using CGrid;

namespace TestCases.UI.Grid
{
	

	/// <summary>Some simple Tests.</summary>
	/// 
	[TestFixture]
    public class GridTest : TestCases.StockData.ProgramContext_TestCases
	{
        CGrid.GridWindow gridWindow;
        string tradeSystem = "TestTrader";
		[SetUp] 
		public void Init() 
		{
            gridWindow = new GridWindow();
			
		}
		
		[Test] 
		public void Quotes()
		{
            
            gridWindow.GridBase.CreateGrid(CUtil.GridTypes.Quotes, true);
            Quote q = new Quote();
            q.DATE = new DateTime(2003, 12, 1);
            q.HIGH = 0.1F;
            q.LOW = 0.1F;
            q.OPENc= 0.1F;
            q.CLOSEc = 0.1F;
            q.VOLUME = 100;

            gridWindow.GridBase.AddRow_Single(q, false);

            q = new Quote();
            q.DATE = new DateTime(2003, 12, 2);
            q.HIGH = 0.2F;
            q.LOW = 0.2F;
            q.OPENc = 0.2F;
            q.CLOSEc = 0.2F;
            q.VOLUME = 200;

            gridWindow.GridBase.AddRow_Single(q, false);


            gridWindow.ShowDialog();



		}
        [Test]
        public void ShareDetails()
        {

            gridWindow.GridBase.CreateGrid(CUtil.GridTypes.ShareDetails, true);
            gridWindow.ShowDialog();



        }
        [Test]
        public void TradeSystem_SingleLine()
        {

            gridWindow.GridBase.CreateGrid(CUtil.GridTypes.TradeSystem, true);

            TradeSystemFactory tradeSystemFactory = new TradeSystemFactory();
            tradeSystemFactory.Create("TestTrader");

            gridWindow.GridBase.AddRow_Single(tradeSystemFactory.StockObjectBase, false);
            gridWindow.ShowDialog();
            



        }
        [Test]
        public void TradeSystem()
        {

            gridWindow.GridBase.CreateGrid(CUtil.GridTypes.TwoColumnGrid, true);

            TradeSystemFactory tradeSystemFactory = new TradeSystemFactory();
            tradeSystemFactory.Create("TestTrader");

            gridWindow.GridBase.AddRow_ForEachProperty(tradeSystemFactory.StockObjectBase);
            gridWindow.ShowDialog();




        }
        [Test]
        public void CreateProfile_And_Save()
        {
            TradeSystemFactory tradeSystemFactory = new TradeSystemFactory();
            tradeSystemFactory.Create(tradeSystem);
            tradeSystemFactory.Serialize();

            
        }
        [Test]
        public void TradeSystem_Show_And_Save()
        {

            gridWindow.GridBase.CreateGrid(CUtil.GridTypes.TwoColumnGrid, true);

            TradeSystemFactory tradeSystemFactory = new TradeSystemFactory();
            tradeSystemFactory.Create(tradeSystem);

            if(tradeSystemFactory.DeSerialize())
            {

                gridWindow.GridBase.AddRow_ForEachProperty(tradeSystemFactory.StockObjectBase);
                if (gridWindow.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    object o = gridWindow.GridBase.SelectedObject;

                }
                object k = gridWindow.GridBase.SelectedObject;

                tradeSystemFactory.StockObjectBase = k as StockObjectBase;

                tradeSystemFactory.Serialize();


            }

        }
		
	
	}
	
}